<?php
namespace App\Logic\ZiNiao\Api;

use App\Libs\ZiNiao\RequireAppToken;
use App\Libs\ZiNiao\RequireOpenClient;
use App\Libs\ZiNiao\RPARequest\PlansRequest;
use Exception;
class Plans
{
    /**
     * 查询计划详情
     * @param array $bizContent ['planId' => "138903"]
     * @return mixed
     */
    public function exe($bizContent)
    {
        $openClient = RequireOpenClient::getInstance();
        $requireAppToken = new RequireAppToken();
        $appAuthToken = $requireAppToken->getAppToken($openClient);
        $request = new PlansRequest();
        $request->setBizContent(json_encode($bizContent));
        $result = $openClient->executeAppToken($request,$appAuthToken);// 发送请求
        $result_decode = json_decode($result);
        if (($result_decode->code === 0 or $result_decode->code === '0') and !isset($result_decode->sub_code)) {
            $data = $result_decode->data;
            if ($data->code === 0 or $data->code === '0') {
                return $data->data;
            }else{
                report(new Exception('Plans失败:' . $data->msg,216));
                return 0;
            }
        }else {
            report(new Exception('Plans失败:' . $result,216));
            return 0;
        }
    }
}
